<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>信息完善</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="/css/LArea.css">
</head>
<style>
    .container {
        display: flex;
        flex-direction: column;
        padding: 0 10px;
    }

    .label {
        font-weight: 600;
        margin-top: 8px;
        font-size: 16px;
    }

    select,
    input {
        font-size: 14px;
        height: 40px;
        margin-top: 6px;
        padding: 0 10px;
        border: 1px solid #d9d9d9;
        border-radius: 4px
    }

    /*input {*/
    /*    font-size: 14px;*/
    /*    height: 40px;*/
    /*    margin-top: 6px;*/
    /*    padding: 0 10px;*/
    /*    border: 1px solid #d9d9d9;*/
    /*    border-radius: 4px*/
    /*}*/

    button {
        height: 44px;
        margin-top: 10px;
        background-color: #0E8CFE;
        color: white;
        border-radius: 5px;
    }

    span {
        color: red;
        font-size: 12px;
    }

    .hide {
        display: none;
    }

    select {
        background: transparent;
        color: rgb(118, 118, 118);
    }
</style>

<body>
<div class="container">
    <div class="label">基础信息</div>
    <input id="zhiMaScore" type="text" placeholder="芝麻信用分(必填)。如:789" />
    <!--    <input id="wxAccount" type="text" placeholder="微信账号(必填)"/>-->
    <!--    <div class="label">银行卡信息</div>-->
    <!--    <input id="bankType" type="text" placeholder="开户行(必填)"/>-->
    <!--    <input id="bankAccount" type="text" placeholder="银行卡号(必填)"/>-->

    <!--    <div class="label">家庭住址</div>-->
    <!--    <span> *</span>-->
    <!--    <input id="input_area" type="text" readonly="" name="input_area" placeholder="省市区选择(必填)"/>-->

    <!--    <input id="addressDetail" type="text" placeholder="居住地地址(必填)"/>-->
    <!--    <select id="resiStatus">-->
    <!--        <option value="">请选择居住状况(必填)</option>-->
    <!--        <option value="1">自置</option>-->
    <!--        <option value="2">按揭</option>-->
    <!--        <option value="3">亲属楼宇</option>-->
    <!--        <option value="4">集体宿舍</option>-->
    <!--        <option value="5">租房</option>-->
    <!--        <option value="6">共有住宅</option>-->
    <!--        <option value="12">借住</option>-->
    <!--        <option value="9">未知</option>-->
    <!--    </select>-->
    <!--    <input id="resiPc" type="text" placeholder="居住地邮编(必填)"/>-->
    <!--    <select id="ocrSex">-->
    <!--        <option value="">请选择性别(必填)</option>-->
    <!--        <option value="1">男</option>-->
    <!--        <option value="2">女</option>-->
    <!--    </select>-->
    <!--    <input id="ocrNation" type="text" placeholder="民族(必填)"/>-->
    <!--    <input id="ocrIssueOrg" type="text" placeholder="发证机关(必填)"/>-->

    <!--    <div style="margin-top: 10px">身份有效开始时间:<input id="ocrStartValidDate" type="date"-->
    <!--                                                  style="margin-left: 10px;height: 30px"/></div>-->
    <!--    <div style="margin-top: 10px">身份有效截止时间:<input id="ocrEndValidDate" type="date"-->
    <!--                                                  style="margin-left: 10px;height: 30px"/>-->
    <!--    </div>-->
    <!--    <input id="ocr_input_area" type="text" readonly="" name="input_area" placeholder="身份证省市区选择(必填)"/>-->
    <!--    <input id="ocrAddressDetail" type="text" placeholder="身份证详细地址(必填)"/>-->

    <div class="label">紧急联系人1</div>
    <input id="contactName" type="text" placeholder="姓名(必填)" />
    <input id="contactPhone" type="text" placeholder="电话(必填)" />
    <select id="contactRelation">
        <option value="">请选择关系(必填)</option>
        <option value="1">父母</option>
        <option value="2">子女</option>
        <option value="3">兄弟姐妹</option>
        <option value="4">朋友</option>
        <option value="5">配偶</option>
        <option value="6">亲戚</option>
        <option value="7">同学</option>
        <option value="8">同事</option>
        <option value="9">其他</option>
    </select>

    <div class="label">紧急联系人2</div>
    <input id="contactName2" type="text" placeholder="姓名(必填)" />
    <input id="contactPhone2" type="text" placeholder="电话(必填)" />
    <select id="contactRelation2">
        <option value="">请选择关系(必填)</option>
        <option value="1">父母</option>
        <option value="2">子女</option>
        <option value="3">兄弟姐妹</option>
        <option value="4">朋友</option>
        <option value="5">配偶</option>
        <option value="6">亲戚</option>
        <option value="7">同学</option>
        <option value="8">同事</option>
        <option value="9">其他</option>
    </select>



    <!--    <div class="label">婚姻信息</div>-->
    <!--    <select id="marriStatus" onchange="marriStatusChange()">-->
    <!--        <option value="">请选择婚姻状况(必填)</option>-->
    <!--        <option value="10">未婚</option>-->
    <!--        <option value="20">已婚</option>-->
    <!--        <option value="30">丧偶</option>-->
    <!--        <option value="40">离婚</option>-->
    <!--        <option value="99">未知</option>-->
    <!--    </select>-->
    <!--    <input id="spoName" type="text" placeholder="配偶名称"/>-->
    <!--    <input id="spoTel" type="text" placeholder="配偶电话"/>-->
    <!--    &lt;!&ndash;    <input id="spoIdNum" type="text" placeholder="配偶身份证号码"/>&ndash;&gt;-->
    <!--    <input id="spsCmpyNm" type="text" placeholder="配偶工作单位"/>-->

    <!--    <div class="label">请选择职业信息</div>-->
    <!--    <input id="cpnName" type="text" placeholder="单位名称(必填)"/>-->
    <!--    <input id="cpnAddr" type="text" placeholder="单位地址(必填)"/>-->

    <button id="tijiao">提交</button>
</div>
<script src="/js/LArea.js"></script>
<script src="/js/areaData.js"></script>
<script src="/url.js"></script>
<script src="/jquery-3.5.1.min.js"></script>


<script src="/app.js"></script>
<script src='/js/alert.js'></script>
<script type="text/javascript">
    let area = new LArea();
    area.init({
        'trigger': '#input_area',//触发选择控件的文本框，同时选择完毕后name属性输出到该位置
        'valueTo': '#value1',//选择完毕后id属性输出到该位置
        'keys': { id: 'code', name: 'value' },//绑定数据源相关字段 id对应valueTo的value属性输出 name对应trigger的value属性输出
        'type': 1,//数据源类型
        'data': areaData//数据源
    });

    let area1 = new LArea();
    area1.init({
        'trigger': '#ocr_input_area',//触发选择控件的文本框，同时选择完毕后name属性输出到该位置
        'valueTo': '#value2',//选择完毕后id属性输出到该位置
        'keys': { id: 'code', name: 'value' },//绑定数据源相关字段 id对应valueTo的value属性输出 name对应trigger的value属性输出
        'type': 1,//数据源类型
        'data': areaData//数据源
    });


</script>
<script>
    var userAgent = navigator.userAgent;
    if (userAgent.indexOf('AlipayClient') > -1) {
        // 支付宝小程序的 JS-SDK 防止 404 需要动态加载，如果不需要兼容支付宝小程序，则无需引用此 JS 文件。
        document.writeln('<script src="https://appx/web-view.min.js"' + '>' + '<' + '/' + 'script>');
    } else if (/QQ/i.test(userAgent) && /miniProgram/i.test(userAgent)) {
        // QQ 小程序
        document.write(
            '<script type="text/javascript" src="https://qqq.gtimg.cn/miniprogram/webview_jssdk/qqjssdk-1.0.0.js"><\/script>'
        );
    } else if (/miniProgram/i.test(userAgent) && /micromessenger/i.test(userAgent)) {
        // 微信小程序 JS-SDK 如果不需要兼容微信小程序，则无需引用此 JS 文件。
        document.write('<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"><\/script>');
    } else if (/toutiaomicroapp/i.test(userAgent)) {
        // 头条小程序 JS-SDK 如果不需要兼容头条小程序，则无需引用此 JS 文件。
        document.write(
            '<script type="text/javascript" src="https://s3.pstatp.com/toutiao/tmajssdk/jssdk-1.0.1.js"><\/script>');
    } else if (/swan/i.test(userAgent)) {
        // 百度小程序 JS-SDK 如果不需要兼容百度小程序，则无需引用此 JS 文件。
        document.write(
            '<script type="text/javascript" src="https://b.bdstatic.com/searchbox/icms/searchbox/js/swan-2.0.18.js"><\/script>'
        );
    } else if (/quickapp/i.test(userAgent)) {
        // quickapp
        document.write('<script type="text/javascript" src="https://quickapp/jssdk.webview.min.js"><\/script>');
    }
    if (!/toutiaomicroapp/i.test(userAgent)) {
        document.querySelector('.post-message-section').style.visibility = 'visible';
    }
</script>
<script type="text/javascript" src="/js/uni.webview.1.5.2.js"></script>
<script type="text/javascript">

    function getData() {
        let userInfo = {}
        // let address = ['', '', '']
        // address[0] = areaData[area.value[0]].value
        // address[1] = areaData[area.value[0]].child[area.value[1]].value
        // address[2] = areaData[area.value[0]].child[area.value[1]].child[area.value[2]].value
        // let addressDetail = document.getElementById('addressDetail').value
        // userInfo.homeAddress = address.join('-') + '-' + addressDetail
        // userInfo.resiStatus = document.getElementById('resiStatus').value
        // userInfo.resiPc = document.getElementById('resiPc').value
        userInfo.zhiMaScore = document.getElementById('zhiMaScore').value
        // userInfo.wxAccount = document.getElementById('wxAccount').value
        // userInfo.bankType = document.getElementById('bankType').value
        // userInfo.bankAccount = document.getElementById('bankAccount').value

        let firstContactInfo = {}
        firstContactInfo.contactName = document.getElementById('contactName').value
        firstContactInfo.contactPhone = document.getElementById('contactPhone').value
        firstContactInfo.contactRelation = document.getElementById('contactRelation').value

        firstContactInfo.contactName2 = document.getElementById('contactName2').value
        firstContactInfo.contactPhone2 = document.getElementById('contactPhone2').value
        firstContactInfo.contactRelation2 = document.getElementById('contactRelation2').value

        // let mariInfo = {}
        // mariInfo.marriStatus = document.getElementById('marriStatus').value
        // mariInfo.spoName = document.getElementById('spoName').value
        // mariInfo.spoTel = document.getElementById('spoTel').value
        // // mariInfo.spoIdNum = document.getElementById('spoIdNum').value
        // mariInfo.spsCmpyNm = document.getElementById('spsCmpyNm').value

        // let eduInfo = {}
        // eduInfo.eduLevel = document.getElementById('eduLevel').value
        // eduInfo.acaDegree = document.getElementById('acaDegree').value

        // let career = {}
        // career.cpnName = document.getElementById('cpnName').value
        // career.cpnAddr = document.getElementById('cpnAddr').value
        // career.empStatus = document.getElementById('empStatus').value
        // career.cpnType = document.getElementById('cpnType').value
        // career.industry = document.getElementById('industry').value
        // career.occupation = document.getElementById('occupation').value
        // career.title = document.getElementById('title').value
        // career.techTitle = document.getElementById('techTitle').value
        // career.socialNum = document.getElementById('socialNum').value
        // career.fundNum = document.getElementById('fundNum').value
        // career.salaryNum = document.getElementById('salaryNum').value

        let id = new URLSearchParams(location.href.split('?')[1]).get("id")
        let data = {}

        data.userId = id
        data.rentalUserIdentity = userInfo
        // data.creditByMariInfo = mariInfo
        data.creditByContactInfo = firstContactInfo
        // data.creditByEduInfo = eduInfo
        // data.creditByCareer = career
        console.log(data)

        let reg = /^[0-9]+$/;
        if (!reg.test(userInfo.zhiMaScore)) {
            myAlert(window.eruptSiteConfig.logoText, '芝麻分请输入数字', function () {

            });
            return
        }

        post(data)
    }

    function post(data) {
        var url = requestUrl + "/app/user/addOtherInfo";
        $.ajax({
            type: "POST",
            url: url,
            data: {
                content: JSON.stringify(data)
            },
            datatype: "json",
            success: function (result) {
                if (result.code == 1) {
                    if (/miniProgram/i.test(userAgent) && /micromessenger/i.test(userAgent)) {
                        myAlert(window.eruptSiteConfig.logoText, '提交成功，请返回继续实名', function () {
                            uni.navigateBack({
                                delta: 1
                            });
                        });
                    } else if (userAgent.indexOf('AlipayClient') > -1) {
                        myAlert(window.eruptSiteConfig.logoText, '提交成功，请返回继续实名', function () {
                            my.postMessage({
                                'type': '__yanzhen__',
                                status: 1
                            })
                        });
                    } else {
                        myAlert(window.eruptSiteConfig.logoText, '提交成功，请返回继续实名', function () {
                            // window.top.history.back()
                            window?.history?.back() || uni.navigateBack({
                                delta: 1
                            });

                            //window.top.history.back(-2)
                        });
                    }
                } else {
                    alert(result.msg)
                }
            },

        });
    }
    document.querySelector('#tijiao').addEventListener('click',
        function () {
            getData()
        }
    );
    // document.addEventListener('UniAppJSBridgeReady', function() {
    //     document.querySelector('#tijiao').addEventListener('click',
    //         function() {
    // alert('aaaa')
    //             getData()
    //         });
    // });
</script>

</body>

</html>